<template>
    <div :key="dealWithKey">
        <special ref="dealWithRef" :parameter="parameterData" @successReturn="successReturn" @updatedSuccess="updatedSuccess"/>
    </div>
</template>
<script>
import special from './special.vue'
import {getSqsxBm} from './service/index.js'
export default {
    components:{
        special,
    },
    props:{
        parameter:{
            type:Object,
            default:() => {}
        }
    },
    data(){
        return{
            parameterData:{},
            dealWithKey:null,
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getDatas(val){
            //console.log('没有数据进来吗？',val)
            this.$store.dispatch('UpdateSpinningPrice', {key:true,stateKey:'modalSpinningPrice'})
            if(val.sqsxid){
                getSqsxBm({sqsxid:val.sqsxid}).then(res=>{
                    if(res.code == 200){
                        val['sqsxbm'] = res.result
                        //console.log('获取到什么啊！',val)
                        this.parameterData = val
                        this.dealWithKey = Date.now()
                        this.$nextTick(()=>{
                            this.$store.dispatch('UpdateSpinningPrice', {key:true,stateKey:'modalSpinningPrice'})
                            this.$refs.dealWithRef.getDatas(val)
                        })
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }else{
                this.$nextTick(()=>{
                    this.$store.dispatch('UpdateSpinningPrice', {key:true,stateKey:'modalSpinningPrice'})
                    this.$refs.dealWithRef.getDatas(val)
                    this.parameterData = val
                })
            }
            
        },
        updatedSuccess(){
            this.$emit('updatedSuccess')
        },
        successReturn(val){
            this.$emit('successReturn',val)
        },
        linkHandlingReturn(val){
            //console.log('到中间拿到什么',val)
            this.$emit('linkHandlingReturn',val)
        }
    }
}
</script>